<?php

namespace Core\Widget;


class WidgetFactory {

    public  static  $_WIDGET_NOT_FOUND_NAME = 'WidgetNotFound';

    /**
     * @param $name
     * @return WidgetAbstract
     */
    public function getWidget($name){
        if(!$name || strlen($name) == 0)
            return self::getErrorWidget();

            $className = __NAMESPACE__.'\\'.'Widget'.$name;
            $widgetClass = new $className();

        return $widgetClass;
    }

    public function getErrorWidget(){
        return $this->getWidget(self::$_WIDGET_NOT_FOUND_NAME);
    }
}